package org.nvm.test;

import java.util.ArrayList;
import java.util.List;

public class LemmaPath {

	private Lemma[] lemmas = null;
	
	public LemmaPath(List<Lemma> list) {
		lemmas = list.toArray(new Lemma[]{});
	}
	
	public double caculate() {
		double result = 10;
		if(lemmas != null && lemmas.length > 0) {
			int length = lemmas.length;
			int[] lens = new int[lemmas.length];
			for(int i = 0; i < length; i ++) {
				lens[i] = lemmas[i].getLength();
			}
			
			result = - LemmaUtil.variance(lens);
		}
		return result;
	}
	
	public List<String> getText(String text) {
		List<String> rs = new ArrayList<>(lemmas.length);
		for(Lemma l : lemmas) {
			rs.add(text.substring(l.getBegin(), l.getBegin() + l.getLength()));
		}
		return rs;
	}
}
